@(p:models.Post, logedUser:Option[String])(implicit s:dao.Session)
<div id="post">
  <div class="spiner"></div>
  <div id="pheader">
    <h3>@p.title</h3>
  </div>
  
  <div id="pcontent">
    @if( logedUser.map( _ == p.author.name).getOrElse(false) ){
      <a href="#" class="profile-action link-button link-button-glyph edit-glyph" onclick="edit_post(@p.id)">Editar</a>
    }
    
    @if( logedUser.map( _ != p.author.name).getOrElse(false) ){
      <a id="fave" class="profile-action link-button link-button-glyph fave-glyph" href="#" onclick="fave()">Destacar</a>
      <a id="unfave" class="profile-action link-button" style="display:none" href="#" onclick="unfave()">Quitar de favoritos</a>
    }
    <div id="pbody">
      <div id="media" class="wide-400">
        <!-- switch content types -->
        @if(p.resource.kind.id == models.MediaKind.IMAGE.id){
          <img src="@p.resource.url" alt="Archivo de referencia" />
        }
        
        @if(p.resource.kind.id == models.MediaKind.VIDEO.id){
          @views.Application.html.video("http://localhost:9000" + p.resource.url, p.resource.url.split('.').last)
        }
        
        @if(p.resource.kind.id == models.MediaKind.SOUND.id){
          <p>audio goes here</p>
        }
        
      </div>
      <p>@p.content</p>
      <form id="loc-data">
        <input type="hidden" id="loc-lat" value="@p.location.latitude" />
        <input type="hidden" id="loc-lng" value="@p.location.longitude" />
      </form>
    </div>
    <table id="pfooter">
      <tr>
        <td id="loc-caption" class="ta-left">@p.location
        </td>
        <td class="ta-right">
          @p.author.name
          @if( logedUser.map( _ != p.author.name).getOrElse(false) ){
            <a href="#" onclick="show_author('@p.author.name')">(ver perfil)</a> 
          }
        </td>
      </tr>
      <tr>
        <td class="ta-left">@p.year</td>
        <td class="ta-right">@p.created</td>
      </tr>
      <tr>
        <td><a href="#" class="link-button" onclick="show_comments()">Ver comentarios</a></td>
        <td><a href="#" class="link-button link-button-glyph comment-glyph" onclick="add_comment()">Agregar comentario</a></td>
      </tr>
    </table>
  </div>

  <div id="pform" style="display:none">
    <form id="pcomment">
      <p>Opina, comenta y construye esta comunidad.</p>
      <textarea id="comment-text" name="content"></textarea>
      <input type="button" id="comment-submit" onclick="process_comment()" value="Comentar" />
      <input type="hidden" name="pid" id="pid" value="@p.id" />
      <a href="#" class="link-button" onclick="reset_comment()">Cancelar</a>
    </form>
  </div>

  <div id="plist" style="display:none">
    <a href="#" class="link-button link-button-glyph back-glyph" onclick="reset_comment()">(volver)</a>
    <a href="#" class="link-button link-button-glyph comment-glyph" onclick="add_comment()">Agregar comentario</a>
    <ul id="pcomments" class="thread-view">
    </ul>
  </div>
</div>

<div id="post-author" style="display:none">
  <a href="#" class="link-button link-button-glyph back-glyph" onclick="hide_author()">(volver)</a>
  <div id="author-placeholder"></div>
  <div class="spiner"></div>
</div>
